/**
 * @properties={typeid:35,uuid:"2D794618-9D41-4418-94A4-9ED7AEB61DEA",variableType:-4}
 */
var fPrueba = null;


/**
 * Callback method when form is (re)loaded.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"1782A1A5-844B-4EBF-9BA3-1B806A096856"}
 */
function onLoad(event) {
	/*
	* id (object) [required] : row id
	* pid (object) [required] : parent row id
	* treeColumn (string) [required] : tree nodes label
	* column1, ... n (string) [optional] : row columns label
	* icon (string) [optional] : servoy media file name
	* editable (string) [optional] : 'false' | null row columns editable flag, null means editable
	*/
	
	var $sql = 'SELECT ensayo_id as "id", padre_id as "pid", e.descripcion as "treeColumn", res.descripcion as "column1", nombre_lista as "column2", \'false\' as "editable" '
				+' FROM ensayos "e" '
				+' LEFT OUTER JOIN resultados_cab "r" ON e.resultados_cab_id = r.resultado_cab_id '
				+' LEFT OUTER JOIN tipo_resultado "res" ON e.tipo_resultado = res.tipo_resultado_id '
	var ds = databaseManager.getDataSetByQuery('cepario',$sql,null,-1)
	ds.addRow(1,["id", "pid", "Ensayos", "Resultado", "Lista" , "editable"])
	
	//elements.arbol.setStyleSheet('treeview { background-color: #ffffff; color: #000000; border-style: solid; font: bold 10pt Verdana; }');
	elements.arbol.setDataSet(ds)
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"62969B79-EE5E-404F-B921-515137AF0D63"}
 */
function onAction(event) {
	fPrueba = application.createJPGImage(elements.arbol,410, 440);
}
